Attribute VB_Name = "AnsHdrV2"
'----------------------------- VB VERSION -----------------------------
'-------------------------Modified for QB4.5---------------------------

Type tRes                   '16 bytes
    dV As Double            'value of item
    dUNC As Double          'uncertainty in item
End Type

Type MaterialStruct             '34 bytes
    MtlKey As Integer
    MtlName As String * 10
    z1 As Integer
    z2 As Integer
    z3 As Integer
    f1 As Single
    f2 As Single
    f3 As Single
    Density As Single
End Type

'
'*************************************************************
'
'   New ANS Spectrum Header Configuration for spectrum, type 2
'
'*************************************************************

Type ANSHead2
    rev As Integer                  '[0000]  Revision Code (2)

    '--- General Information
    id As String * 72               '[0002]  Spectrum id
    RESV0074 As String * 6      '[0074]  General reserved area + alignment
    StartDate As Double             '[0080]  Time in Windows Format Acq First Started
    StopDate As Double              '[0088]  Time in Windows format Acq Last Ended
    
    '--- Status Information
    ElapsedRT As Double             '[0096]  Elapsed real time in sec: xxx.xx
    ElapsedLT As Double             '[0104]  Elapsed live time in sec: xxx.xx
    ElapsedPass As Long             '[0112]  Elapsed number of passes
    DeadTime As Single              '[0116]  Instantaneous deadtime during acquire
                                    '        Average deadtime after acquire
    ElapsedCount As Double          '[0120]  Elapsed count.

    '--- Hardware Setup - Bias
    BiasOn As Integer               '[0128]  On/Off
    BiasCtrl As Integer             '[0130]  HV Bias Control word:  xxxxSSSSAAAAxxxP
                    '        SSSS = shutoffs, AAAA = alarms: spare, extern, LN2, leak
                    '        P = bias polarity (0 = negative, 1 = positive)
    BiasSetPt As Single             '[0132]  Set Point for Bias Supply
    BiasVoltage As Single           '[0136]  Voltage Setting
    BiasCurrentLimit As Single      '[0140]  Current Limit in ma
    RESV0144 As String * 16         '[0144]  Reserved for bias info

    '--- Hardware Setup - AMP
    AMPCoarseGain As Single         '[0160]  Coarse Gain
    AMPFineGain As Single           '[0164]  Fine Gain
    AMPPoleZero As Single           '[0168]  Pole Zero
    AMPShapingTime As Single        '[0172]  Shaping time constant in microseconds
    AMPFastThresh As Single         '[0176]  Fast threshold setting (-100% to +100% )        #REV1
    AmpBLRThresh As Single          '[0180]  (formerly AmpType)
    AmpShape As Integer             '[0184]  0 = Bipolar Gaussian, 1 = Unipolar Gaussian,    #REV2
                                    '           2 = Gated Integrator, 3 = Triangular            #REV2
    AMPCTRL As Integer              '[0186]  Bitwise control word xxxx xBUF PxI+ paRr
                                    '        B = BLR rate high; U = BLR user adjusted;
                                    '        F = fast disc user adjusted; P = pos ext inhib pol
                                    '        I = ext inhib on; + = positive input pol
                                    '        p = ext preamp; a = ext amp; R = pos reject; r = reject on
    PreampType As Integer           '[0188]  Preamp type (0 = TrReset/PulOpt, !0 = other)
    RSRV0190 As String * 34         '[0190]  Reserved for amp info

    '--- Hardware Setup - ADC
    ADCMode As Integer              '[0224]  Operating Mode 0=PHA, 1=MCS, 2=SVAH, 3=SVAL
    ADCCtrl As Integer              '[0226]  ADC control word:  0000 0000 0PUL S0rR
                                    '        P = pos peak det; U = place pulses over ULD in last chan
                                    '        L = pos LGO; S = ext sync; r = reject input on;
                                    '        R = pos reject in pol
    ADCGate As Integer              '[0228]  Gate Mode  0000 0000 0000 0EMM
                                    '        MM = 0 (off), 1 (anticoin), 2 (coin)
                                    '        E = 0 (level triggered), 1 (edge trig)
    ADCDTMode As Integer            '[0230]  Dead Time Mode: 0000 0000 000B IMMM
                                    '        B = pos ADC busy out; I = pos ADC deadtime in
                                    '        MMM = 0 (simple busy), 1 (Lowes), 2 (Gedcke-Hale), 3 (extern)
    ADCConvMode As Integer          '[0232]  Type of conversion 0=Lin, 1=QCC
    ADCMCSMode As Integer           '[0234]  MCS Mode: 0000 0000 SAPa IIII
                                    '        S = extern sync, A = pos ext adv pol
                                    '        P = pos ext pulse pol; a = ext advance
                                    '        I = 0 (internal), 1 (SCA), 2 (ICR), 3 (ext), 4 (ROI)
    ExtADCCtrl As Integer           '[0236]  Bit settings for external ADC (PCAX, etc.)
    ExtOutBits As Integer           '[0238]  Bit settings of external outputs
    ADCZero As Single               '[0240]  ADC Zero Adjust
    ADCLLD As Single                '[0244]  Low Level Discriminator
    ADCULD As Single                '[0248]  Upper Level Discriminator
    ADCConvGain As Integer          '[0252]  256, 512, ... 8192...
    ADCGroupSz As Integer           '[0254]  256, 512, ... 8192...
    ADCGroup As Integer             '[0256]  Current Group
    ADCDigOff As Integer            '[0258]  ADC Digital Offset
    ADCGSMode As Integer            '[0260]  Gain Stabilizer mode (0 = off, 1 = edge, 2 = ROI)
    ADCGSROIStart As Integer        '[0262]  Gain Stab start region
    ADCGSROIEnd As Integer          '[0264]  Gain Stab end region
    ADCGSROI As Integer             '[0266]  Gain Stab associated ROI number
    ADCGSOffset As Single           '[0268]  Gain Stab Current Value of correction
    ADCGSTau As Single              '[0272]  Gain Stab Time period (seconds)
    ADCGSRange As Single            '[0276]  Gain Stab Range of Correction
    ADCZSMode As Integer            '[0280]  Zero Stabilizer mode (0 = off, 1 = edge, 2 = ROI)
    ADCZSROIStart As Integer        '[0282]  Zero Stab start region
    ADCZSROIEnd As Integer          '[0284]  Zero Stab end region
    ADCZSROI As Integer             '[0296]  Zero Stab associated ROI number
    ADCZSOffset As Single           '[0288]  Zero Stab Current Value of correction
    ADCZSTau As Single              '[0292]  Zero Stab Time period (seconds)
    ADCZSRange As Single            '[0296]  Zero Stab Range of Correction
    ADCDwlSmpTime As Single         '[0300]  Dwell time or sample interval (seconds)         #REV2
    ADCPasses As Long               '[0304]  Number of passes for MCS
    RESV0308 As String * 28         '[0308]  Reserved for ADC expansion

    '--- Hardware Setup - Presets
    PresetON As Integer             '[0336]  Presets are on if true
    RSRV0338 As Integer         '[0338]  [Alignment]
    PresetRT As Long                '[0340]  Real Time Preset
    PresetLT As Long                '[0344]  Live Time Preset
    PresetPK As Long                '[0348]  Peak Preset
    PresetCount As Double           '[0352]  Count Presets (replaces Integ preset)
    PresetCntROI As Integer         '[0360]  ROI which is to serve for preset ROI
    PresetCntMode As Integer        '[0362]  Preset Counts mode (1 = ROIS) ##REVx GHN 970224
    RESV0364 As String * 4      '[0364]  Reserved for presets
    
    '--- Hardware on which spectrum was taken
    DevName As String * 16          '[0368]  Device name
    DevType As Integer              '[0384]  Numeric ID of Device Type: 1=PCAP,2=PCAM, 5=PCA3
    DevAddr As Integer              '[0386]  Bus address of device
    DevUnit As Integer              '[0388]  Unit number: (0-7) for P&3, (IEEE addr 1-16)
    DevID As Integer                '[0390]  Pointer record in SPECD.PRM
    RESV0392 As Integer             '[0392]  (Formerly device capabilities)
    DevStatus As Integer            '[0394]  Device Status
    hPORT As Integer                '[0396]  Port handle (not valid from one session to another)
    hdev As Integer                 '[0398]  Device handle (not valid from one session to another)
    RESV0400 As String * 16     '[0400]  Reserved for device info

    '--- Energy Calibration Data
    EnCalFlag As Integer            '[0416]  Flag for valid energy calibration
    EnCalType As Integer            '[0418]  Type of energy calibration (0 = linear, 1 = sqrt)
    RESV0420 As Long                '[0420]  (Formerly EnCalKey, pointer to calibration data in database)
    EnCal0 As Single         '[0424]  Calibration constants
    EnCal1 As Single         '[0424]  Calibration constants
    EnCal2 As Single         '[0424]  Calibration constants
    EnCal3 As Single         '[0424]  Calibration constants
    EnCalUnits As String * 4        '[0440]  X axis calibration units
    EnergyShift As Single           '[0444]  Amount this spectrum is shifted from the nominal energy calibration
    RESV0448 As String * 16     '[0448]  Reserved for energy calibration

    '--- Shape Calibration Data
    ShCalFlag As Integer            '[0464]  Flag for valid shape calibration
    ShCalType As Integer            '[0466]  Type of equation represented
    RESV0468 As Long                '[0468]  (Formerly ShCalKey, pointer to calibration data in database)
    ShCal0 As Single         '[0472]  Calibration constants
    ShCal1 As Single         '[0472]  Calibration constants
    ShCal2 As Single         '[0472]  Calibration constants
    ShCal3 As Single         '[0472]  Calibration constants
    RESV0488 As String * 8      '[0488]  Reserved for shape calibration

    '--- Efficiency Calibration data
    EfCalFlag As Integer            '[0496]  Flag for valid efficiency calibration
    EfCalType As Integer            '[0498]  Type of equation represented
    RESV0500 As Long                '[0500]  (Formerly EfCalKey, pointer to calibration data in database)
    EfCal0 As Single         '[0504]  Calibration constants
    EfCal1 As Single         '[0504]  Calibration constants
    EfCal2 As Single         '[0504]  Calibration constants
    EfCal3 As Single         '[0504]  Calibration constants
    EfCal4 As Single         '[0504]  Calibration constants
    EfCal5 As Single         '[0504]  Calibration constants
    EfCal6 As Single         '[0504]  Calibration constants
    EfCal7 As Single         '[0504]  Calibration constants
    EfCal8 As Single         '[0504]  Calibration constants
    EfCalUnc As Single              '[0540]  Calibration uncertainty
    RESV0544 As String * 48     '[0544]  Reserved for efficiency and other calibrations

    '--- Background Model Data
    BkgModelFlag As Integer         '[0592]  Flag for valid background model
    BkgModelType As Integer         '[0594]  Type of equation represented
    RESV0596 As Long                '[0596]  (Formerly BkgModelKey, pointer to calibration data in database)
    BkgModel0 As Single      '[0600]  Calibration constants
    BkgModel1 As Single      '[0600]  Calibration constants
    BkgModel2 As Single      '[0600]  Calibration constants
    BkgModel3 As Single      '[0600]  Calibration constants
    RESV0616 As String * 8      '[0616]  Reserved for background model

    '--- Detector
    DETType As Integer              '[0624]  Detector Type, ie, 0=Scint, 1=SiLi, 2=HpGe(P), ...
    DetShape As Integer             '[0626]  Detector shape: 0 = Cyl, 1 = Well, 2 = Coax
    DetID As String * 12            '[0628]  Detector Name
    DetThickness As Single          '[0640]  Thickness of detector
    DetDiameter As Single           '[0644]  Diameter of detector
    DetWellDia As Single            '[0648]  Diameter of well
    DetWellDepth As Single          '[0652]  Depth of well
    DetSourceDist As Single         '[0656]  source to detector distance
    DetIncAngle As Single           '[0660]  incident angle to detector 0 = normal
    DetWinThick0 As Single   '[0664]  Window thicknesses in microns
    DetWinThick1 As Single   '[0664]  Window thicknesses in microns
    DetWinThick2 As Single   '[0664]  Window thicknesses in microns
    DetWinThick3 As Single   '[0664]  Window thicknesses in microns
    DetMtl0 As MaterialStruct '[0680]  Keys for the materials in the detector definitions
    DetMtl1 As MaterialStruct '[0680]  Keys for the materials in the detector definitions
    DetMtl2 As MaterialStruct '[0680]  Keys for the materials in the detector definitions
    DetMtl3 As MaterialStruct '[0680]  Keys for the materials in the detector definitions
    DetDeadLayer As Single          '[0816]  Detector dead layer in cm
    DetBiasOptimum As Single        '[0820]  Optimim Bias for this detector
    DetBiasMax As Single            '[0824]  Maximum Bias for this detector
    RESV828 As String * 4      '[0828]  Reserved for detector

    '---Tool Settings
    PKmode As Integer               '[0832]  find peaks convolution type
    PKpwr As Integer                '[0834]  find peaks convolution avg threshold
    PKintg As Integer               '[0836]  find peaks convolution integral threshold
    BKGwidth As Integer             '[0838]  find peaks bkg width
    BKGspread As Single             '[0840]  find peaks bkg gap as multiplier of FWHM
    ROIwidth As Single              '[0844]  find peaks ROI width as multiple of FWHM
    BKGROIRange As Integer          '[0848]  Acceptable range for manual bkg roi (chans)
    AppType As Integer              '[0850]  Spectroscopy type being performed
                                    '        0 = Gamma, 1 = Beta, 2 = Alpha,
                                    '        3 = EBEAM, 4 = XRAY, 5 = PIXE
    AnalysisCtrl As Integer         '[0852]  Flags for analysis: 0000 0000 0000 00CA
                                    '           C = no continuum correc; A = no ambient correc
    EMatchMode As Integer           '[0854]  0 = a * FWHM, 1 = a + b*E
    EwinA As Single                 '[0856]  EMatch a
    EwinB As Single                 '[0860]  EMatch b
    PKminengy As Single             '[0864]  Low energy cutoff for peak search
    PKmaxuncer As Single            '[0868]  Acceptable statistical uncertainty
    MDAKa As Single                '[0872]  Ka for MDA calculation
    MDAKb As Single                '[0876]  Kb for MDA calculation
    EnFullScale As Integer          '[0880]  Full scale energy of calib in keV
    XaxisLabel As String * 12       '[0882]  Label which replaces Energy on X-axis
    RESV0894 As String * 10     '[0894]  Reserved for tool settings

    '--- Sample information
    SampleKey As Long               '[0904]  Link to Sample Database
    SampQuantity As Single          '[0908]  Amount of sample in user specified units
    SampQuantUnc As Single          '[0912]  Uncertainty in amount of sample
    SampUnits As String * 4         '[0916]  User specified units for sample quantity
    SampActivDate As Double         '[0920]  Date to report activity as of
    
    '--- Reserved space
    RESV0928 As String * 80         '[0928]  General reserved space
    
    '--- Data to describe additional sections of file
    SpecStart As Integer            '[1008]  First channel in file
    SpecEnd As Integer              '[1010]  Last Channel in file
    NZAPs As Integer                '[1012]  Number of ZAP structures included in file
    NROIs As Integer                '[1014]  Number of ROIStructs in file
    RESV1016 As String * 4      '[1016]  Reserved for other block counters
    AcqSysType As Integer           '[1020]  System type designator
    AcqSysLen As Integer            '[1022]  Length of Parameter block following header

'
'   New Extension
'
    file As String * 256            '[1024] File name of spectrum

    '--- EDS/XRF info
    Exctype As Integer              '[1280]  Type of excitation 1 = ebeam, 2 = xray tube, 3 = isotope
    ExcNuc As String * 6            '[1282]  Isotope or element
    ExcEnergy As Single             '[1288]  Energy of excitation in keV
    ExcCurrent As Single            '[1292]  Excitation Beam Current
    ExcIncAngle As Single           '[1296]
    DetHeight As Single             '[1300]
    DetInsertDepth As Single        '[1304]
    DetXtlAngle As Single           '[1308]
    TkOffAngle As Single            '[1312]  angle between sample normal and vector to detector
    DetAxisElev As Single           '[1316]
    DetAzimuth As Single            '[1320]
    RESV1324 As Single              '[1324]  Formerly DetElevation
    WorkDist As Single              '[1328]
    SampXtilt As Single             '[1332]
    SampYtilt As Single             '[1336]
    RESV1340 As String * 24         '[1340]  Reserved for more EDS/XRF info

    '--- EDS Analysis Controls
    EDSMu As Integer                '[1364]  Select Mass Absorption Coefficient Selection
    EDSJump As Integer              '[1366]                                                  #REV2
    EDSQCross As Integer            '[1368]  Selects fluorescence cross section calculation  #REV2
    EDSStopFact As Integer          '[1370]                                                  #REV2
    EDSFYield As Integer            '[1372]  Selects which Fluorescence Yield calculation is used
    EDSMeanIonPot As Integer        '[1374]  Selects Mean ionization Model
    EDSFluor As Integer             '[1376]  Selects which Fluorescence calculations is used
    EDSAbsorp As Integer            '[1378]  Selects which absorption calculation is used
    EDSRfact As Integer             '[1380]  Selects which Rfactor calculation is used
    RESV1382 As String * 26         '[1382]  Reserved for EDS analysis expansion

    '--- Reserved
    RESV1408 As String * 128        '[1408]  General reserved area
End Type

Type ROIDat                         '50 bytes (as stored in files)
    id As String * 12               'ROI name
    StrEnergy As Single             'ROI start energy
    EndEnergy As Single             'ROI end energy
    Nuclide As String * 8           'Nuclide Pointer
    Htype As Integer                 'Hardware Tag
    Integral As Double              'Gross Integral
    Centroid As Single              'Centroid (no BKG Correction)
    Peak As Single                  'Peak location in ROI (no BKG sub)
    FWHM As Single                  'FWHM (w/ BKG correction)
End Type

Type QuantROI                       '240 bytes (as passed to DLLs)
    id As String * 12               '[000-011] ROI name
    Nuclide As String * 6           '[012-017] nuclide associated with this line
    Rtype As Integer                 '[018-019] roi type
    GrossCounts As tRes             '[020-035] Gross counts in region
    BKGCounts As tRes               '[036-051] Background counts in region
    ConCounts As tRes               '[052-067] Continium Counts in Region
    NetCounts As tRes               '[068-083] Net counts in region
    Activity As tRes                '[084-099] Activity
    StrEnergy As Single             '[100-103] starting energy of ROI
    EndEnergy As Single             '[104-107] ending energy of ROI
    Centroid As Single              '[108-111] background subtracted centroid
    Center As Single                '[112-115] centroid of positive lobe of convolution
    Peak As Single                  '[116-119] Highest channel in gross region
    FWHM As Single                  '[120-123] FWHM (w/ BKG correction)
    M2 As Single                    '[124-127] second moment of non-continium subtracted dist
    M3 As Single                    '[128-131] third moment of non-continium subtracted dist
    DetEff As tRes                  '[132-147] detector efficiency for this line
    SumCorr As tRes                 '[148-163] summing correction for this line  *** added 3/15/96
    MDA As Single                   '[164-167] minimum detectable activity
    MPA As Single                   '[168-171] Maximum permissible activity in Bq
    Yield As tRes                   '[172-187] Line Intensity from database
    TXInt As Single                 '[188-191] transform positive lobe integral
    TXAvg As Single                 '[192-195] average value of transform
    Ewindow As Single               '[196-199] window within which a peak is considered matched
    Corr As Single                  '[200-203] correlation coefficient associated with this line
    Hits As Integer                 '[204-205] number of matches at this energy
    MatchPtr As Integer             '[206-207] pointer to a matching parameter
    TmpInfo As Single               '[208-211] Used to temporarily hold info for calibration 970322
    Fill As String * 28             '[212-239] Fill For later expansion         *** revised 970323
End Type

Type BkgROI                         '20 bytes
    StrEnergy As Single             '[00-03] starting energy of ROI
    EndEnergy As Single             '[04-07] ending energy of ROI
    Center As Single                '[08-11] center channel = (start + end)/2
    AvgCounts As Single             '[12-15] Average number of counts per channel
    AvgCountsUnc As Single          '[16-19] Uncertainty in average counts
End Type

'Type QROIsDat                       '12 + 240 * MAXROI + 20 * MAXBROI bytes
'    No As Integer                   'number of foreground ROIs defined
'    ptr As Integer                  'current foreground ROI
'    bkgno As Integer                'number of BkgROIs defined
'    bkgptr As Integer               'current BkgROI
'    ptrisbkg As Integer             'if set, use bkgptr for cur ROI
'    pad As Integer                  'round out to mult of 4
'    BROI(1 To MAXBROI) As BkgROI    'array of background ROI structures
'    QROI(1 To MAXROI) As QuantROI   'array of foreground ROI structures
'End Type
